package cn.rdq.iknesssystem.controller;

import cn.rdq.api.po.EpisodeSrc;
import cn.rdq.api.vo.EpisodeSrcVo;
import cn.rdq.common.CommonResult;
import cn.rdq.iknesssystem.service.EpisodeSrcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/episode-src")
public class EpisodeSrcController {

    @Autowired
    private EpisodeSrcService episodeSrcService;

    @PostMapping("/list")
    public CommonResult list(@RequestBody EpisodeSrcVo episodeSrcVo) {
        List<EpisodeSrc> listEpisode = episodeSrcService.listEpisode(episodeSrcVo);
        return CommonResult.successObj(listEpisode);
    }

    @GetMapping("/del/{id}")
    public CommonResult delete(@PathVariable Long id) {
        episodeSrcService.deleteById(id);
        return CommonResult.success();
    }

    @PostMapping("/add")
    public CommonResult add(@RequestBody EpisodeSrc episodeSrc) {
        episodeSrcService.saveEpisodeSrc(episodeSrc);
        return CommonResult.success();
    }
}
